package com.fivemin.website_statistics.service.impl;

import com.fivemin.website_statistics.dao.WebUserMapper;
import com.fivemin.website_statistics.enums.ResponseEnum;
import com.fivemin.website_statistics.pojo.WebUser;
import com.fivemin.website_statistics.service.WebUserService;
import com.fivemin.website_statistics.vo.R;
import com.fivemin.website_statistics.vo.WebUserVo;
import com.mysql.jdbc.Wrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class WebUserServiceImpl implements WebUserService {
    @Autowired
    private WebUserMapper webUserMapper;

    @Override
    public R addWebUser(WebUser webUser) {
//        try{
            String keyValue = UUID.randomUUID().toString();
            String secret = UUID.randomUUID().toString();
            webUser.setkeyValue(keyValue);
            webUser.setSecret(secret);
            webUserMapper.insert(webUser);
            WebUserVo webUserVo = new WebUserVo(webUser);
            return R.builder().build().OK(webUserVo);
//        }catch (Exception e){
//            return new R().error(ResponseEnum.DB_SAVE_ERROR,null);
//        }
    }

    @Override
    public R getWebUserList(int pageNum, int pageSize) {
//        webUserMapper.selectList();
        return null;
    }

    @Override
    public R disableWebUserById(int id) {
        return null;
    }
}
